<template>
    <p-search-item class="p-customer-search" v-model="currentValue" :labelWidth="labelWidth" @reset="resetForm" @submit="submit">
        <template #search>
            <el-form-item label="用品名称：">
                <el-input size="mini" clearable placeholder="请输入用品名称" v-model="currentValue.suppliesName"></el-input>
            </el-form-item>
            <el-form-item label="用品编号：">
                <el-input size="mini" clearable placeholder="请输入用品编号" v-model="currentValue.suppliesCode"></el-input>
            </el-form-item>
        </template>
    </p-search-item>
</template>
<script>
    import pSearchItem from '../../../components/p-search-box.vue';
    /**
     *   - Author by clj. on 2020.4.16
     *     demo file
     *              - 搜索组件
     * */
    export default {
        name: 'dome-search',
        components: { pSearchItem },
        props: {
            value: {
                // form表单对象
                type: Object,
                default: () => {}
            },
            labelWidth: {
                // label的宽度
                type: String,
                default: '74px'
            },
            searchFunc: Function // 回调的提交函数
        },
        data() {
            return {
                currentValue: this.value,
                loading: false,
                treeData:[]    //用品分类数据
            };
        },
        watch: {
            value(val) {
                this.currentValue = val;
            },
            currentValue(val) {
                this.$emit('input', val);
            }
        },
        created() {
            this.init();
        },
        methods: {
            init() {

            },
            resetForm() {
                // 重置，所有form字段清空、或赋默认值。 Author by clj. on 2019.3.1
                this.currentValue = {};
            },
            submit() {
                // 查询。 Author by clj. on 2019.3.1
                if (typeof this.searchFunc === 'function') {
                    this.searchFunc().then(res => {
                        // console.log('dict-search.submit.callback: ', res);
                    });
                }
            }
        }
    };
</script>

<style rel="stylesheet/scss" lang="scss">

</style>
